package com.anpy.bill.controller;

import com.anpy.bill.entity.MemoDetailEntity;
import com.anpy.bill.entity.MemoDetailImgEntity;
import com.anpy.bill.entity.MemoEntity;
import com.anpy.bill.model.param.DateLineParam;
import com.anpy.bill.model.param.MemoDetailDeleteParam;
import com.anpy.bill.model.param.MemoDetailParam;
import com.anpy.bill.service.MemoService;
import com.anpy.common.service.model.result.ApiResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author : anpengyu
 * @create 2024/8/5 13:50
 */
@RestController
@RequestMapping("/memo")
@ResponseBody
public class MemoController {

    @Resource
    private MemoService memoService;

    @PostMapping("/detail/save")
    public ApiResult<String> save(@RequestBody MemoDetailParam memoDetailParam) {
        boolean saveResponse = memoService.saveMemoDetail(memoDetailParam);
        return ApiResult.success();
    }

    @GetMapping
    public ApiResult<List<MemoEntity>> memoList(Long userId) {
        List<MemoEntity> list = memoService.memoList(userId);
        return ApiResult.success(list);
    }

    @GetMapping("/detail")
    public ApiResult<List<MemoDetailEntity>> memoDetailList(Long userId,Long memoId) {
        List<MemoDetailEntity> list = memoService.memoDetailList(userId,memoId);
        return ApiResult.success(list);
    }

    @GetMapping("/detail/img")
    public ApiResult<List<MemoDetailImgEntity>> memoDetailImgList(Long userId,Long memoId) {
        List<MemoDetailImgEntity> list = memoService.memoDetailImgList(userId,memoId);
        return ApiResult.success(list);
    }

    @PostMapping("/detail/delete")
    public ApiResult<Boolean> memoDetailDelete(@RequestBody MemoDetailDeleteParam memoDetailDeleteParam) {
        Boolean result = memoService.memoDetailDelete(memoDetailDeleteParam.getUserId(),memoDetailDeleteParam.getMemoId());
        return ApiResult.success(result);
    }
}
